using System;
using System.Web; 
using System.Text; 
using System.Collections;
using System.Collections.Specialized;
using Castle.MonoRail.Framework;
using Castle.MonoRail.Framework.Internal;

using eduSrc.Models;
using eduSrc.Services;

namespace eduSrc.Web.viewComponents
{
    public class PartRender : ViewComponent
    {
        private readonly eduSrcCatalogService _eduSrcCatalogService = eduSrcCatalogService.GetInstance();

        private string _moduleCnOne = string.Empty;
        private string _moduleCnTwo = string.Empty;

        public string ModuleCnOne
        {
            get { return _moduleCnOne; }
            set { _moduleCnOne = value; }
        }

        public string ModuleCnTwo
        {
            get { return _moduleCnTwo; }
            set { _moduleCnTwo = value; }
        }

        public override void Initialize()
        {
            _moduleCnOne = (String)ComponentParams["ModuleCnOne"];
            _moduleCnTwo = (String)ComponentParams["ModuleCnTwo"];

            base.Initialize();
        }

        public override void Render()
        {
            StringBuilder _textString = new StringBuilder();
            HtmlContext _htmlContext = _eduSrcCatalogService.htmlContextByModuleCn(_moduleCnOne, _moduleCnTwo);
            if (_htmlContext != null)
            {
                _textString.Append(_htmlContext.Context); 
            }
            RenderText(_textString.ToString()); 
        }
    }
}
